import cv2 as cv


image = cv.imread('/Users/apple/Desktop/data/lena.jpg')
image = cv.pyrDown(image)
cv.imshow('Original image', image)


# 均值平滑、高斯平滑、中值平滑(椒盐噪点)，其中默认5x5的滤波器
blurImg = cv.blur(image, (5, 5))
GasImg = cv.GaussianBlur(image, (5, 5), 0)
medImg = cv.medianBlur(image, 5)


# 数学形态平滑(开运算、闭运算)
element = cv.getStructuringElement(cv.MORPH_CROSS, (5, 5))
morOpImg = cv.morphologyEx(image, cv.MORPH_OPEN, element, iterations=1)
morCloImg = cv.morphologyEx(image, cv.MORPH_CLOSE, element, iterations=1)


cv.imshow('Blur image', blurImg)
cv.imshow('Gaussian Blur image', GasImg)
cv.imshow('Median image', medImg)
cv.imshow('morphology open image', morOpImg)
cv.imshow('morphology close image', morCloImg)


cv.waitKey()
cv.destroyAllWindows()
